package com.boot.mgt.controller.web

import com.boot.core.result.ResultTo
import com.boot.core.util.ManagerKit
import com.boot.mgt.service.AccidentFileService
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*
import org.hsqldb.DatabaseManager.getSession
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpSession




/**
 * 事故管理ctroller
 * xiaying
 */
@RestController
@RequestMapping("/admin/gpsManager")
class AccidentFileController {

    @Autowired
    private lateinit var accidentFileService: AccidentFileService

    /**
     * 获取事故信息列表
     */
    @GetMapping("/list")
    fun list(request: HttpServletRequest, page_index: Int?, page_size:Int?, sglx:Int?,has_latlon:Int?, sgfs_time_begin:String?, sgfs_time_end:String?): ResultTo {
        var xqdw= request.getAttribute(ManagerKit.ORG_NUM).toString()
        return accidentFileService.list(page_index?:1, page_size?:20,has_latlon?:0,sgfs_time_begin, sgfs_time_end, xqdw as String?,sglx)
    }
    companion object {
        private val log: Logger = LoggerFactory.getLogger(this::class.java)
    }

    /**
     *根据事故ID修改，更新事故发生地点的经纬度坐标
     */
    @PostMapping("/set_coordinates")
    fun setCoordinates(acd_file_id:Int,latitude:String, longitude:String): ResultTo {
        return accidentFileService.setCoordinates(acd_file_id, latitude, longitude)
    }

    /**
     * 根据ID查找详情
     */
    @GetMapping("/detail")
    fun detail(sgbh:String): ResultTo {
       return accidentFileService.detail(sgbh)
    }
}

